    public interface IDbHelper
    {
        //连接到数据库
        void Connect();
        //获取数据
        void GetData();
    }

    public class MySqlHelper : IDbHelper
    {
        public void Connect()
        {
            System.Console.WriteLine("连接到MySql");
        }

        public void GetData()
        {
            System.Console.WriteLine("获取MySql的数据");
        }

    }

    public class RedisHelper : IDbHelper
    {
        public void Connect()
        {
            System.Console.WriteLine("连接到 redis");
        }

        public void GetData()
        {
            System.Console.WriteLine("获取Redis的数据");
        }
    }

    public abstract class absService
    {
        private IDbHelper DbHelper;

        public absService(IDbHelper dbHelper)
        {
            this.DbHelper = dbHelper;
        }

        public void DoSomething()
        {
            this.DbHelper.Connect();
            this.DbHelper.GetData();
        }
    }

    public class LogService : absService
    {
        private IDbHelper dbObject;

        public LogService(IDbHelper dbHelper) : base(dbHelper) { }
    }

    public class ReportService : absService
    {
        private IDbHelper dbObject;

        public ReportService(IDbHelper dbHelper) : base(dbHelper) { }
    }

    class Program
    {
        public static void Main(string[] args)
        {
            IDbHelper redisHelper = new RedisHelper();
            IDbHelper mySqlHelper = new MySqlHelper();

            LogService logService = new LogService(mySqlHelper);
            ReportService reportService = new ReportService(redisHelper);

            logService.DoSomething();
            reportService.DoSomething();
        }
    }